<div class="panel panel-default" style="margin-bottom:80px;">
    <div class="panel-body">
        <ul class="nav">
            <h4>修改权限</h4>
        </ul>
        <form class="form-horizontal ajaxform" ajaxSuccess="success" ajaxAlways="always" method="post" action="/role_privilege/save">
            <input type="hidden" name="role_id" value="{{.role_id}}" />
            {{range $navigator := .navigators}}
            <h4><span class="label label-default">{{$navigator.name}}</span> <span class="small"><input name="privilege_id" type="checkbox" data-type="navigator" value="{{$navigator.privilege_id}}" onclick="Role.privilege(this)" /></span></h4>
            {{range $menu := $.menus}} {{if eq $menu.parent_id $navigator.privilege_id}}
            <ul class="list-group w240 inline-group">
                <li class="list-group-item"><strong>{{$menu.name}}</strong> <span class="pull-right"><input name="privilege_id" type="checkbox" data-type="menu" value="{{$menu.privilege_id}}" onclick="Role.privilege(this)" /></span></li>
                {{range $controller := $.controllers}} {{if eq $controller.parent_id $menu.privilege_id}}
                <li class="list-group-item">{{$controller.name}}<span class="pull-right"><input name="privilege_id" type="checkbox" data-type="controller" value="{{$controller.privilege_id}}" onclick="Role.privilege(this)" /></span></li>
                {{end}} {{end}}
            </ul>
            {{end}} {{end}} {{end}}
            <div class="form-group">
                <div class="col-md-8" style="margin-left:10px;">
                    <button type="submit" class="btn btn-success">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="/static/style/module/role.js"></script>
<script type="text/javascript">
<!--
var navigators = [];
var menus = [];
var controllers = [];
var defaultPrivileges = [];

{{range $navigator := .navigators }}
    navigators.push({'privilegeId':'{{$navigator.privilege_id}}', 'name':'{{$navigator.name}}', 'parentId':'{{$navigator.parent_id}}', 'type':'{{$navigator.type}}'});
{{end}}

{{range $menu := .menus }}
    menus.push({'privilegeId':'{{$menu.privilege_id}}', 'name':'{{$menu.name}}', 'parentId':'{{$menu.parent_id}}', 'type':'{{$menu.type}}'});
{{end}}

{{range $controller := .controllers }}
    controllers.push({'privilegeId':'{{$controller.privilege_id}}', 'name':'{{$controller.name}}', 'parentId':'{{$controller.parent_id}}', 'type':'{{$controller.type}}'});
{{end}}

{{range $rolePrivilege := .rolePrivileges}}
    defaultPrivileges.push(parseInt({{$rolePrivilege.privilege_id}}))
{{end}}

Role.defaults(defaultPrivileges);
//-->
</script>